package com.twang.stock.rocketMq;


import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RocketMQProducer {


    @Value(value = "${rocketmq.producer.topic}:${rocketmq.producer.oneway-tag}")
    private String onewayTag;


    private static String tag="stock";

    private static String topic="stock-topic";

    @Autowired
    private RocketMQTemplate rocketMQTemplate;


    /**
     *  单项发送
     * @param object
     */
    public void sendOneWay(Object object) {
        try {
            // 发送消息到一个Broker
            rocketMQTemplate.sendOneWay(onewayTag, object);
        } catch (Exception e) {
            log.error(">>>>>>>>> sendOneWay e:{}", e);
        }

    }


}
